survey_df %<>%
  #note that for the "treatment variables" we construct our indicator variables based on missingness. 
  #E.g., our interventions were baked into question text. So if respondent X answered question V_16, it
  #implies that they were in the "CONTROL" condition; if respondent Z answered question V_17 they were in
  #treatment CONDITION 1, and so on.
  mutate(treatment = case_when(!is.na(V_16) ~ "C",
                               !is.na(V_17) ~ "T1",
                               !is.na(V_18) ~ "T2",
                               !is.na(V_19) ~ "T3",
                               !is.na(V_20) ~ "T4")) %>%
  mutate(h1_treat = case_when (!is.na(V_17) | !is.na(V_18) | !is.na(V_19) | !is.na(V_20) ~ 1,
                               !is.na(V_16) ~ 0,
                               TRUE ~ NA_real_)) %>%
  mutate(h2_treat = case_when(!is.na(V_17) | !is.na(V_20) ~ 1,
                              !is.na(V_18) | !is.na(V_19) ~ 0,
                              TRUE ~ NA_real_)) %>%
  mutate(h3_treat = case_when(!is.na(V_17) | !is.na(V_18) ~ 1,
                              !is.na(V_19) | !is.na(V_20) ~ 0,
                              TRUE ~ NA_real_)) %>%
  mutate(attitudinal_outcome = ifelse(!is.na(V_16), as.character(V_16),
                                      ifelse(!is.na(V_17), as.character(V_17),
                                             ifelse(!is.na(V_18), as.character(V_18),
                                                    ifelse(!is.na(V_19), as.character(V_19),
                                                           ifelse(!is.na(V_20), as.character(V_20), NA)))))) %>%
  mutate(attitudinal_outcome = case_when(attitudinal_outcome %in% c("Sangat setuju") ~ 4,
                                         attitudinal_outcome %in% c("Setuju") ~ 3,
                                         attitudinal_outcome %in% c("Tidak setuju") ~ 2,
                                         attitudinal_outcome %in% c("Sangat tidak setuju") ~ 1,
                                         TRUE ~ NA_real_),
         attitudinal_outcome_binary = case_when(attitudinal_outcome %in% c(4, 3) ~ 1,
                                                attitudinal_outcome %in% c(1, 2) ~ 0,
                                                TRUE ~ NA_real_),
         behavioral_outcome = case_when(V_21 == "Tidak akan" ~ 1,
                                        TRUE ~ 0)) %>%
  
  #HTE variables
  mutate(past_attendance = (V_15 == "Ya, pernah")*1) %>%
  mutate(joko_supporter = (V_53 == "Joko Widodo - Ma'ruf Amin")*1) %>%
  mutate(islam = (religion == "Islam")*1)
